#include "files/directory.h"
#include "files/file_item.h"

#include <sys/stat.h>

namespace Tvimeg
{
	FileItem::FileItem(void)
	{
	}

	FileItem::FileItem(const FilePath& path)
		:	FilePath(path)
	{
	}

	bool FileItem::Exists(const bool isDir) const
	{
		struct stat data;
		if (stat(GetPath().c_str(), &data) == 0)
		{
			return S_ISDIR(data.st_mode) == isDir;
		}
		else
		{
			return false;
		}
	}

	time_t FileItem::GetModificationTime(void) const
	{
		struct stat data;
		if (stat(GetPath().c_str(), &data) == 0)
		{
			return data.st_mtime;;
		}
		else
		{
			return 0;
		}
	}

	Directory FileItem::GetParent(void) const
	{
		return Directory(FilePath::GetParent());
	}
}
